<!DOCTYPE html>
<html style="font-size: 23.4375px;">
<head>
    <include file="./public/header.html"/>
    <style>
        .kongge{
            margin-left: 10px;
            width: 200px;
        }
        table td[data-v-3ee98bdd]:first-of-type{
            width: 5rem;
            text-indent: .5em;
        }
    </style>
</head>
<body style="font-size: 21.7589px;">
<div id="app">
    <div id="shadow" style="display: none;"></div>
    <header class="top">
        <span>用户注册</span> <!---->
        <div class="iconfont back" style="display: none;"></div>
        <a href="./index.html" class="iconfont back"></a>
    </header>

    <div data-v-3ee98bdd="" class="main" s="[object Object]">
        <table data-v-3ee98bdd="">
            <tbody data-v-3ee98bdd="">
            <tr data-v-3ee98bdd="">
                <td data-v-3ee98bdd=""><span  class="kongge">邀&nbsp;&nbsp;请&nbsp;&nbsp;码：</span></td>
                <td data-v-3ee98bdd="" colspan="2">
                    <input type="text" name="yaoqingma" id="yaoqingma" data-v-3ee98bdd="" placeholder="请输入邀请码" value="{$code}">
                </td>
            </tr>
            <tr data-v-3ee98bdd="">
                <td data-v-3ee98bdd=""><span  class="kongge">账&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;号：</span></td>
                <td data-v-3ee98bdd="" colspan="2">
                    <input type="text" data-v-3ee98bdd="" name="user" id="user" placeholder="请输入账号" style=""></td>
            </tr>
            <tr data-v-3ee98bdd="">
                <td data-v-3ee98bdd=""><span  class="kongge">设置密码：</span></td>
                <td data-v-3ee98bdd="" colspan="2">
                    <input type="password" name="pass" id="pass1" data-v-3ee98bdd="" placeholder="请输入密码">
                </td>
            </tr>
            <tr data-v-3ee98bdd="">
                <td data-v-3ee98bdd=""><span  class="kongge" style="width: 300px">确认密码：</span></td>
                <td data-v-3ee98bdd="" colspan="2">
                    <input type="password" data-v-3ee98bdd="" name="pass" id="pass2" placeholder="请再次输入密码">
                </td>
            </tr>
            <tr data-v-3ee98bdd="">
                <td data-v-3ee98bdd=""><span  class="kongge">验&nbsp;&nbsp;证&nbsp;&nbsp;码：</span></td>
                <td data-v-3ee98bdd="">
                    <input data-v-3ee98bdd="" placeholder="请输入验证码" id="yanzhengma" type="text" class="userInput">
                </td>
                <td data-v-3ee98bdd="">
                     <span class="anym" style="width: 0px; padding:0; margin:0;">
                         <img id="yzm"  name="yzm" src="/index.php/Api/Swimer/yzm" onclick="this.src='/index.php/Api/Swimer/yzm/time='+Math.random();" style="cursor: pointer;" width="97px" title="点击获取"/>
                     </span>
                </td>
            </tr>
            <tr data-v-3ee98bdd=""></tr>
            </tbody>
        </table>
        <a href="{:U('Index/login')}" class="forget fr" data-v-3ee98bdd="">已有账号? 立即登录</a>

        <div data-v-3ee98bdd="" class="loginBtn BTN mt30">
            <a data-v-3ee98bdd="" onclick="sav1()">立即注册</a>
        </div>
    </div>
</div>
</body>
</html>
<script>
    function sav1(){
        var yaoqingma = $("#yaoqingma").val();
        var user = $("#user").val();
        var pass1 = $("#pass1").val();
        var pass2= $("#pass2").val();
        var yanzhengma = $("#yanzhengma").val();
        if(yaoqingma == ''){
           alert("邀请码不能为空");
            return false;
        }
        if(user == ''){
            alert("账号不能为空");
            return false;
        }
        if(user.length < 6 || user.length > 20 ){
            alert("账号必须是6~20位字母数字或下划线组合");
            return false;
        }
        if(pass1 == ''){
            alert("密码不能为空");
            return false;
        }
        if(pass1.length < 6 || pass1.length > 20 ){
            alert("密码必须是6~20位");
            return false;
        }
        if(pass2 == ''){
            alert("确认密码不能为空");
            return false;
        }
        if(pass1 != pass2){
            alert("两次输入的密码不一致");
            return false;
        }
        if(yanzhengma == ''){
            alert("验证码不能为空");
            return false;
        }

        $.ajax({
            type: "POST",
            url: "{:U('Yz/zhuce_add')}",
            data: {'user':user,'pass':pass1,'yanzhengma':yanzhengma,'yaoqingma':yaoqingma},
            success: function(dat){
                if(dat==1){
                    alert("该账号已存在，请直接登录");
                    return false;
                }else if(dat==2){
                    alert("邀请码不正确，请重新输入");
                    return false;
                }else if(dat==0){
                    alert("验证码不正确，请重新输入");
                    return false;
                }else if(dat==3){
                    window.location.href="{:U('Index/login')}";
                }
            }
        });

    }
</script>
